<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>Excel导入模板管理</title>
<script type="text/javascript">
	var $grid;
	$(function() {
		$grid = $("#grid").datagrid($.extend({}, datagridOption, {
			url : "${ctx}/basic/excelImportTemp/dataGrid",
			fitColumns : true,
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'importTempNo',
				title : '模板编号',
				width : 140,
				sortable : true
			}, {
				field : 'importTempName',
				title : '模板名称',
				width : 140,
				sortable : true
			}, {
				field : 'attach',
				title : '模板附件',
				width : 200,
				formatter : fmt_singleAttach
			}, {
				field : 'remark',
				title : '备注',
				width : 140,
				sortable : true
			} ] ],
			onDblClickRow : function(index, rowData) {
				$.isFunction(fn_edit) && fn_edit.call(this, rowData);
			},
			onClickRow : function(index, row) {
				$('#file_upload').uploadify("settings", 'uploader', '${ctx}/basic/attachment/busUpload/single/' + row.attachmentMaster.id);
			}
		}));

		$grid.datagrid('enableFilter', [ buildDGFilterYesOrNoFieldOptions($grid) ]);
		$("#add").click(function() {
			$("#fm").form("clear");
			$('#fm').form('load', {
				enable : 1
			});
			$("#dlg").dialog("open").dialog("setTitle", "新增Excel导入模板");
		});
		$("#edit").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (!rowData) {
				showInfo("您未选中行，无法编辑");
			} else {
				fn_edit(rowData);
			}
		});
		$("#delete").click(function() {
			multiDeleteDataGrid($grid, "${ctx}/basic/excelImportTemp/multiDelete");
		});
		$("#search").click(function() {
			$grid.datagrid('load', $("#tt").form("getData"));
		});
		setTimeout(function() {
			$('#file_upload').uploadify({
				'swf' : '${ctx}/static/uploadify/uploadify.swf',
				'buttonText' : 'Excel模板上传',
				onUploadSuccess : function(file, data, response) {
					$grid.datagrid("reload");
				}
			});
		}, 10);
	});
	<shiro:hasPermission name="excelImportTemp:update">
	function fn_edit(rowData) {
		$("#dlg").dialog("open").dialog("setTitle", "编辑Excel模板");
		$("#fm").form("clear");
		$("#fm").form("load", rowData);
	}
	</shiro:hasPermission>
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="row">
		<div class="col-md-3">
			<shiro:hasPermission name="excelImportTemp:update">
				<button id="add" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-plus"></span> 新增
				</button>
			</shiro:hasPermission>
			<shiro:hasPermission name="excelImportTemp:delete">
				<button id="delete" type="button" class="btn btn-danger">
					<span class="glyphicon glyphicon-minus"></span> 删除
				</button>
			</shiro:hasPermission>
		</div>
		<div id="uploadDiv" class="col-md-9">
			<input type="file" name="file_upload" id="file_upload" />
		</div>
	</div>
	<shiro:hasPermission name="excelImportTemp:update">
		<div id="dlg" class="easyui-dialog" style="width: 370px; height: 350px; padding: 10px 20px"
			data-options="resizable:true,modal:true, buttons:'#dlg-btn',closed:true">
			<form id="fm" method="post">
				<input type="hidden" name="id" />
				<table id="tbl">
					<tr>
						<td><label>Excel模板标识:</label></td>
						<td><input name="importTempNo" class="easyui-validatebox" data-options="required: true"></td>
					</tr>
					<tr>
						<td><label>Excel模板名称:</label></td>
						<td><input name="importTempName" class="easyui-validatebox" data-options="required: true"></td>
					</tr>
					<tr>
						<td><label>备注:</label></td>
						<td><input name="remark" class="easyui-validatebox" data-options=""></td>
					</tr>
				</table>

			</form>
			<div id="dlg-btn">
				<button id="save" type="button" class="btn btn-primary"
					onclick="formSave('#fm', '#grid', '#dlg', '${ctx}/basic/excelImportTemp/update');">
					<span class="glyphicon glyphicon-ok"></span> 保存
				</button>
				<button id="cancel" type="button" class="btn btn-primary" onclick="$('#dlg').dialog('close');">
					<span class="glyphicon glyphicon-remove"></span> 取消
				</button>
			</div>
		</div>
	</shiro:hasPermission>
</body>
</html>
